<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/9/15 0015
 * Time: 19:54
 */

namespace app\lib\im;

use im\TLSSigAPI;
use think\Config;

class Tls
{
    private $tls;
    public function __construct(){
        $tls=new TLSSigAPI();
        $ds=DIRECTORY_SEPARATOR;
        $tls->setAppid(Config::get("webim.sdkappid"));
        $privatekey=file_get_contents(dirname(__DIR__)."{$ds}keys{$ds}private_key");
        $publickey=file_get_contents(dirname(__DIR__)."{$ds}keys{$ds}public_key");
        $tls->setPrivateKey($privatekey);
        $tls->setPublicKey($publickey);
        $this->tls=$tls;
    }

    public function getUserSig($identifier){
        return $this->tls->genSig($identifier);
    }

}